//
//  SCRefundController.m
//  shangcheng
//
//  Created by 张艳江 on 2019/6/12.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCRefundController.h"
#import "SCRefundGoodsCell.h"
#import "SCRefundTypeCell.h"
#import "SCConfirmRefundController.h"

@interface SCRefundController ()<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView *tableView;
@property (strong, nonatomic) NSArray     *titles;
@property (strong, nonatomic) NSArray     *details;

@end

@implementation SCRefundController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"退货申请";
    self.titles = @[@"退货退款",@"仅退款"];
    self.details = @[@"已收到货，需要退还收到的货物",@"没收到货，或与卖家协商不用退货"];
    //设置tableView
    [self setUpTableView];
}
- (void)setUpTableView{
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-kTopHeight) style:UITableViewStylePlain];
    self.tableView.backgroundColor = BGColor;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorColor = [UIColor clearColor];
    self.tableView.tableFooterView = [UIView new];
    
    //注册
    [self.tableView registerNib:[UINib nibWithNibName:@"SCRefundGoodsCell" bundle:nil] forCellReuseIdentifier:@"SCRefundGoodsCellID"];
    [self.tableView registerNib:[UINib nibWithNibName:@"SCRefundTypeCell" bundle:nil] forCellReuseIdentifier:@"SCRefundTypeCellID"];
    
    [self.view addSubview:self.tableView];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 116;
    }else{
        return 68;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        SCRefundGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SCRefundGoodsCellID"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.model = self.goodsModel;
        return cell;
    }else{
        SCRefundTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SCRefundTypeCellID"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.titleLab.text = self.titles[indexPath.row];
        cell.detailLab.text = self.details[indexPath.row];
        return cell;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1) {
        SCConfirmRefundController *vc = [[SCConfirmRefundController alloc]init];
        vc.goodsModel = self.goodsModel;
        if (indexPath.row == 0) {
            vc.status = @"12";
        }else{
            vc.status = @"11";
        }
        [self.navigationController pushViewController:vc animated:YES];
    }
}



@end
